package Servlet;

import Bean.User;
import Service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.PreparedStatement;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张
 * Date: 2025-03-16
 * Time: 11:57
 */
//展示用户详情 --- 管理员端
@WebServlet("/UserDetailedServlet")
public class UserDetailedServlet extends HttpServlet {
    private UserService userService = new UserService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("application/json;charset=utf8");
        String userId = req.getParameter("userId");
        User user = userService.selectById(userId);
        req.setAttribute("user",user);
        System.out.println("[UserDetailedServlet] 查询到的用户数据为 : " + user.toString());
        req.getRequestDispatcher("user_detailed.jsp").forward(req,resp);
    }
}
